/*
 * Copyright (c) 2001, 2002 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.perforce.core.internal.api;

import java.util.ArrayList;
import java.util.List;

import net.sourceforge.perforce.api.IPerforceCommand;
import net.sourceforge.perforce.core.PerforceCorePlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;

/**
  * ClientUser object for the 'p4 diff' command.
  * 
  * @version $Revision: 252 $
  * @author  <a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  * 
  * TODO: Introduce IDiffResult
  */
public class Diff extends AbstractPerforceCommand implements IPerforceCommand 
{
	// --------------------------------------------------------------------------- Private Variables
	
	/** Stores the result of the operation. */
	private List result = new ArrayList();

	// --------------------------------------------------------------- Public Static Factory Methods
	
	/** Convenience method for creating instances of 'Resolved'. 
	  * 
	  * @return the new Diff instance.
	  */
	public static final Diff newInstance()
	{
		MultiStatus status = 
			new MultiStatus(PerforceCorePlugin.ID, IStatus.OK, "", null);
			
		return new Diff(status);
	}

	// ------------------------------------------------------------------------ Private Constructors
	
	/** Constructor for Diff. 
	  * 
	  * @param status the MultiStatus.
	  */
	private Diff(MultiStatus status)
	{
		super(status);
	}

	// -------------------------------------------------------- Public Methods (IClientUserDelegate)
	
	/** @see IClientUserDelegate#outputInfo(char, String) */
	public void outputInfo(char level, String infoString) 
	{
		result.add(infoString);
	}	

	// ----------------------------------------------------------- Public Methods (IPerforceCommand)
	
	/** @see IPerforceCommand#getCommand() */
	public String getCommand() 
	{
		return "diff";                                                                 //$NON-NLS-1$
	}

	/** @see IPerforceCommand#getStatus() */
	public IStatus getStatus() 
	{
		return getMultiStatus();
	}

	// ------------------------------------------------------------------------------ Public Methods
	
	/** @return the result of the operation. */
	public String[] getResult()
	{
		return (String[]) result.toArray(new String[result.size()]);
	}
}
